import type { BasicFetchResult, BasicPageParams, BasicRecord } from './baseModel';

export type ArticleRecord = BasicRecord & {
  // @Column({ comment: '标题' })
  title: string;
  // @Column({ comment: '内容', type: 'text' })
  content: string;
  // @Column({ comment: '列表内容', type: 'text',nullable:true })
  brief?: string;
  // @Column({ comment: '标签' })
  tag_id: string;
  // @Column({ comment: '栏目' })
  column_id: number;
  // @Column({ comment: '专栏id',nullable:true })
  sp_column_id?: number;
  // @Column({ comment: '用户id' })
  user_id?: number;
  // @Column({ comment: '封面图', nullable: true })
  cover?: string;
  // @Column({ comment: '点赞数', default: 0, nullable: true })
  likes?: number;
  // @Column({ comment: '阅读数', default: 0, nullable: true })
  read?: number;
  // @Column({ comment: '收藏数', default: 0, nullable: true })
  favorites?: number;
  /** 0 已发布文章 1 草稿箱 */
  state?: number;
  /** 0 已发布 1 已下架 2 待更新 3 草稿箱 */
  type?: number;
  user_icon: string;
  user_name: string;
  tag: string;
};

export type AddArticleParams = Pick<
  ArticleRecord,
  'title' | 'content' | 'tag_id' | 'column_id' | 'state' | 'type' | 'cover'
>;

export type ArticleInfoResultModel = ArticleRecord;

export interface ArticleInfoParams {
  id: number;
}

export interface ArticleSpColumnRecord {
  id: number;
  name: string;
  desc: string;
  cover: string;
  subscribe_num: number;
  article_num: number;
  column_id: number;
  user_id: number;
  user_name: string;
  createTime: string;
}
export type ArticleSpColumnModel = BasicFetchResult<ArticleSpColumnRecord>;

export interface ArticleSpColumnParams {
  sorts: string;
  page: number;
  size: number;
  user_id?: number;
  column_id?: number;
}

export type DraftPageParams = BasicPageParams & {};

export type DraftPageGetResultModel = BasicFetchResult<ArticleRecord>;

export type ArticlePageParams = BasicPageParams &
  Pick<ArticleRecord, 'state' | 'type' | 'sp_column_id' | 'title'>;

export type ArticlePageGetResultModel = BasicFetchResult<ArticleRecord>;

export type ArticleListParams = Partial<
  Pick<ArticleRecord, 'type' | 'title' | 'sp_column_id'> & {
    sort: number;
  }
>;
export type ArticleListGetResultModel = ArticleRecord[];

export type CommentRecord = BasicRecord & {
  /** 内容 */
  content: string;
  /** 点赞量 */
  star: number;
  /** 文章 id */
  article_id: number;
  /** 评论人 id */
  user_id: number;
  /** 被评论的评论 id, 如果不是回复消息, 那么这个字段为 0 */
  to_comment_id: number;
  /** 被评论用户 id, 默认是沸点作者 */
  to_user_id: number;
  /** 多级评论需传递顶层评论的 id */
  top_id: number;

  image: string;
  stared: boolean;
};

export type AddCommentParams = Pick<CommentRecord, 'content' | 'article_id'> &
  Partial<Pick<CommentRecord, 'to_comment_id' | 'to_user_id' | 'image' | 'top_id' | 'user_id'>>;

export type AddCommentResult = {
  id: number;
};

export type AddCommentStarParams = { comment_id: number };

export type AddCommentStarResult = Pick<CommentRecord, 'star'>;
